package com.lzh.shijicloudstack.controller;

import com.lzh.shijicloudstack.common.R;
import com.lzh.shijicloudstack.common.ResultUtil;
import com.lzh.shijicloudstack.model.dto.role.RolePageDto;
import com.lzh.shijicloudstack.model.entity.Role;
import com.lzh.shijicloudstack.service.RoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 角色 控制器
 *
 * @author luzhiheng
 * @date 2025/4/24
 */
@Api(tags = "角色模块")
@RestController
@RequestMapping("/role")
public class RoleController {

    @Resource
    private RoleService roleService;

    @ApiOperation(value = "删除角色")
    @PostMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Long id) {
        return roleService.delete(id);
    }

    @ApiOperation(value = "更新角色")
    @PostMapping("/update")
    public R<Boolean> updateRole(@RequestBody Role role) {
        return ResultUtil.success(roleService.updateRole(role));
    }

    @ApiOperation(value = "分页查询")
    @PostMapping("/pageList")
    public R<Map<String, Object>> pageList(@RequestBody RolePageDto dto) {
        return ResultUtil.success(roleService.pageList(dto));
    }
}
